Page 97 - 2629_Devagiri_C-7
P. 97
Program 10 To find if the year entered is leap year or not.
Program10.py
File Edit Format Run Options Window Help
year = int(input("Enter a year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print("It is a leap year.")
else:
print("It is not a leap year.")
Output
Enter a year: 2300
It is not a leap year.
Enter a year: 2024
It is a leap year.
TECH
T ¢ Expression: A combination of values, variables, operators and functions that Python
E evaluates to produce a result.
R
M ¢ Interpreter: A program that reads and executes Python code line by line, converting it to
S machine code.
Execution: The process of running code, where the interpreter executes instructions to
¢
produce results.
REWIND RUN
« The order in which program statements are executed is called the flow of control.
« The if…else… statement lets your program choose between two options.
« The nested if structure allows you to place one if statement inside another.
« The ternary operator allows you to perform conditional checks and assign values or execute expressions
in a single line.
95
Flow of Control in Python

